package com.budgetme.activities;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import com.budgetme.R;
import com.budgetme.graphing.BarGraphView;
import com.budgetme.graphing.GraphView;
import com.budgetme.graphing.GraphViewSeries;
import com.budgetme.graphing.GraphViewSeries.GraphViewData;
import com.budgetme.graphing.LineGraphView;

public class Graph extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.graph_test);

        	  
        	LineGraphView graphView = new LineGraphView(
        	      this // context  
        	      , "GraphViewDemo" // heading  
        	);  
        	graphView.addSeries(new GraphViewSeries(new GraphViewData[] {
        			new GraphViewData(1, 1.0d),
        			new GraphViewData(2, 2.0d),
        			new GraphViewData(3, 3.0d),
        			new GraphViewData(4, 4.0d),
        			new GraphViewData(5, 5.0d),
        			new GraphViewData(6, 6.0d),
        			new GraphViewData(7, 5.0d),
        			new GraphViewData(8, 5.0d),
        			new GraphViewData(9, 4.0d),
        			new GraphViewData(10, 4.0d),
        			new GraphViewData(11, 3.0d),
        			new GraphViewData(12, 3.0d),
        			new GraphViewData(13, 2.0d),
        			new GraphViewData(14, 2.0d),
        			new GraphViewData(30, 1.0d),
        			new GraphViewData(16, 1.0d),
        			new GraphViewData(17, 0.0d),
        			new GraphViewData(18, 0.0d),
        			new GraphViewData(19, -1.0d),
        			new GraphViewData(20, -1.0d),
        			new GraphViewData(21, -2.0d),
        			new GraphViewData(22, -3.0d),
        			new GraphViewData(23, -2.0d),
        			new GraphViewData(24, -1.0d),
        			new GraphViewData(25, 0.0d),
        			new GraphViewData(26, 1.0d),
        			new GraphViewData(27, 2.0d),
        			new GraphViewData(28, 3.0d),
        			new GraphViewData(29, 4.0d),
        			new GraphViewData(15, 5.0d)
        	}));
        	
        	graphView.setHorizontalLabels(new String[] {
        			"1",
        			"2",
        			"",
        			"4",
        			"",
        			"6",
        			"",
        			"8",
        			"",
        			"10",
        			"",
        			"12",
        			"",
        			"14",
        			"",
        			"16",
        			"",
        			"18",
        			"",
        			"20",
        			"",
        			"22",
        			"",
        			"24",
        			"",
        			"26",
        			"",
        			"28",
        			"",
        			"30"
        	});
        	
        	graphView.setVerticalLabels(new String[] {
        		"9",
        		"6",
        		"3",
        		"0",
        		"-3",
        		"-6"
        	});
        	
        	double maxY = graphView.getMaxY();
        	double minY = graphView.getMinY();
        	
        	double uBoundY = (maxY > 0) ? maxY + 3 : 3;
        	double lBoundY = (minY < 0) ? minY - 3 : -3;
        	
        	graphView.formatLabel(3, true);
        	
        	graphView.setManualYAxisBounds(uBoundY, lBoundY);
        	
        	graphView.setDrawBackground(true);
        	graphView.setManualYCenterValue(0);
        	  
        	LinearLayout layout = (LinearLayout) findViewById(R.id.graph_layout);  
        	layout.addView(graphView);
        
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
//        getMenuInflater().inflate(R.menu., menu);
        return true;
    }
    
}
